#define DATA_T char*
#include "Tree.h"

int main()
{
    tree* Tree = MakeTree("Database.txt");
tree_filedump(Tree, "Dump.txt");
    tree* Node = Tree;
    int end = 0;
    while (!end)
    {
        if (Node -> left || Node -> right)
        {
            printf("%s?\n", Node -> data);
            char answer = getchar(); getchar();
            if (answer == 'y') Node = Node -> right;
            else Node = Node -> left;
        }
        else
        {
            printf("Is it %s?\n", Node -> data);
            char answer = getchar(); getchar();
            if (answer == 'y')
            {
                printf("I'm clever\nDo you wish to continue?\n");
                char answer = getchar(); getchar();
                if (answer == 'y') Node = Tree;
                else end = 1;
            }
            else
            {
                printf("Who have you thought of?\n");
                char* str = (char*) calloc(100, sizeof(char));
                scanf("%s", str);
                add_node(Node, new_node(str), 'r');
                add_node(Node, new_node(Node -> data), 'l');
                printf("How %s is different from %s?\n", str, Node -> data);
                char* str2 = (char*) calloc(100, sizeof(char));
                scanf("%s", str2);
                Node -> data = str2;
                tree_filedump(Tree, "Database.txt");
                printf("Do you wish to continue?\n");
                char answer = getchar(); getchar();
                if (answer == 'y') Node = Tree;
                else end = 1;
            }
        }
    }
    return 0;
}
